Export Function

I have wirtten a code that generate a textbox with attributes of the current view and some other things.
After i generate the "results" i export the text into a textfile.

I have two button, generate and export. If i press generate there will be a preview of the data information in a textbox.

The problem is if i change or add some text in the preview and export, there is no different in the export textfile.

To understand the problem better here i have the code:

// Layout (Dialog box) & Export

DBE retry
DBE exportFile
DBE calcStab
DBE t1
DBE fn

void calcStability (DBE) {

collectStabData()
results2 = results
set (t1,results)

}
void exportFileFunc (DBE) {

selectedFile = get(fn)

if (results2 == "")
{errorBox " 1.step generate! "
return}

string filenameData = selectedFile

testFile = canOpenFile(filenameData,false)
if (testFile "" == "true")
{if (confirm "Datei \"" filenameData "\" Overwirte?")
else
halt}
{Stream outData = write filenameData

results2 = results2 "\n"

outData << results2

close outData

s = ""
set (t1,"copy and saved: " filenameData "\n" results)

infoBox "Data \"" filenameData "\" generate."
}

} // Ende Exportfile
void retry(DBE) {
show exBox
t1=text(exBox, "", results, 500, 500, false)
}

t1 = text(exBox,"",results, 500, 500, false)

fn = fileName(exBox, initFile, "*.txt", "Export to")

calcStab = button(exBox,"Generate", calcStability)

beside exBox

exportFile = button(exBox,"Export", exportFileFunc)

show exBox

// Ende Layout
SystemAdmin - Mon Sep 13 03:00:37 EDT 2010

Re: Export Function
SystemAdmin - Mon Sep 13 03:20:22 EDT 2010

"void retry(DBE) {
show exBox
t1=text(exBox, "", results, 500, 500, false)
}"

This codetext is rubbish, it was a try to clear the textbox before i generate the textbox

Re: Export Function
Mathias Mamsch - Mon Sep 13 03:49:04 EDT 2010

First of all, alway use "{ C O D E }" when posting code, so that the formatting does not get lost.

If you want to take into account changes of the textbox, you must read the contents of the textbox before doing the export. You only do:
 

void calcStability (DBE) {
    collectStabData()
    results2 = results // store the results in result2 (for whatever reason)
    set (t1,results)
}
 
// ... 
 
void exportFileFunc (DBE) {
    // ...
 
    // Please uncomment me
    // results2 = get t1   // read the textbox contents before writing it to a file
 
    // write them to the file. Ignore the stuff the user changed
   outData << results2
 
   // ...
}

 


In general your code does not have a very good structure, you should rename your variables to better reflect their contents. Statements like:

 

 

 

if (testFile "" == "true")
{if (confirm "Datei \"" filenameData "\" Overwirte?")
else
halt}
{Stream ...
}



make my toenails roll up :-) Your braces are mixed up. Therefore try structuring your code better:



 

 

 

 

if (testFile "" == "true") {
   if (!confirm "...") halt
} 
// continue with the export



Hope this helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Export Function
SystemAdmin - Mon Sep 13 04:24:39 EDT 2010

Mathias Mamsch - Mon Sep 13 03:49:04 EDT 2010

First of all, alway use "{ C O D E }" when posting code, so that the formatting does not get lost.

If you want to take into account changes of the textbox, you must read the contents of the textbox before doing the export. You only do:
 

void calcStability (DBE) {
    collectStabData()
    results2 = results // store the results in result2 (for whatever reason)
    set (t1,results)
}
 
// ... 
 
void exportFileFunc (DBE) {
    // ...
 
    // Please uncomment me
    // results2 = get t1   // read the textbox contents before writing it to a file
 
    // write them to the file. Ignore the stuff the user changed
   outData << results2
 
   // ...
}

 


In general your code does not have a very good structure, you should rename your variables to better reflect their contents. Statements like:

 

 

 

if (testFile "" == "true")
{if (confirm "Datei \"" filenameData "\" Overwirte?")
else
halt}
{Stream ...
}



make my toenails roll up :-) Your braces are mixed up. Therefore try structuring your code better:



 

 

 

 

if (testFile "" == "true") {
   if (!confirm "...") halt
} 
// continue with the export



Hope this helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Okay thank you for your tips. It works.
One little thing and the programm is perfect.

Actually if i press the button "generate" serval times, every time the "result" text generate under the exists text.
I don't know where i integrate
this code.

set(t1,"")

 


Do you have any idea?

 

Re: Export Function
SystemAdmin - Mon Sep 13 07:36:21 EDT 2010

SystemAdmin - Mon Sep 13 04:24:39 EDT 2010

Okay thank you for your tips. It works.
One little thing and the programm is perfect.

Actually if i press the button "generate" serval times, every time the "result" text generate under the exists text.
I don't know where i integrate
this code.

set(t1,"")

 


Do you have any idea?

 

If i use this code, it doesn't work
 

void calcStability (DBE) {
    collectStabData()
        set (t1,"")
        set (t1,results)
        }

Re: Export Function
SystemAdmin - Tue Sep 14 03:19:10 EDT 2010

SystemAdmin - Mon Sep 13 07:36:21 EDT 2010

If i use this code, it doesn't work
 

void calcStability (DBE) {
    collectStabData()
        set (t1,"")
        set (t1,results)
        }

Does any have an idea?

Re: Export Function
Mathias Mamsch - Tue Sep 14 13:48:42 EDT 2010

SystemAdmin - Tue Sep 14 03:19:10 EDT 2010
Does any have an idea?

You probably should clear your "results" buffer:

setempty results

 


before writing it to the text box again. Regards, Mathias

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS